package com.mshop.service;

import java.util.List;

import com.mshop.fw.modules.CommonService;
import com.mshop.fw.util.DESUtil;
import com.mshop.fw.util.StringUtil;
import com.mshop.po.Drivers;
import com.mshop.util.QL;

public class DriversService extends CommonService {

	/*public List<Drivers> list(int startRows, int rows) {
		return list("", startRows, rows);
	}*/

	public List<Drivers> list(String key, int startRows, int rows) {
		if (StringUtil.isEmpty(key)) {
			key = "";
		}
		String secKey="";
		DESUtil des;
		try {
			des = new DESUtil();
			secKey=des.encrypt(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return dao.find(Drivers.class, QL.HQL.Drivers.LIST_BY_KEY,
				new Object[] {key, secKey , secKey }, startRows, rows);
	}

/*	public Long getCount() {
		return getCount(null);
	}*/

	/**
	 * @param key
	 * @return
	 */
	public Long getCount(String key) {
		if (StringUtil.isEmpty(key)) {
			key = "";
		}
		String secKey="";
		DESUtil des;
		try {
			des = new DESUtil();
			secKey=des.encrypt(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return dao.getCount(QL.HQL.Drivers.GET_COUNT_KEY, new Object[] {  key, secKey ,secKey});
	}

	public void save(Drivers Drivers) {
		dao.save(Drivers);
	}

	public Drivers load(String id) {
		return dao.load(Drivers.class, new Long(id));
	}

	public Drivers get(String id) {
		return dao.get(Drivers.class, new Long(id));
	}

	public void delete(String id) {
		dao.delete(this.get(id));
	}

}
